Completed
Push — master ( c8cc0a...f17656 )
by Thomas
44s
created

Module.getManifest   B

Complexity

Conditions 6
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 6
c 1
b 0
f 0
nc 3
dl 0
loc 12
rs 8.8571
nop 2
1
'use strict'
2
3
const jsonfile = require('jsonfile')
4
const output = require('../output')
5
6
var Module = {}
7
8
/**
9
 * Get the manifest object for the module in the current directory.
10
 * @param {function(ModuleManifest)} callback
11
 */
12
Module.getManifest = function (callback) {
13
  jsonfile.readFile('module.json', function (err, module) {
14
    if (err) {
15
      output.err('Error reading module.json: ' + err)
16
      return
17
    }
18
    if (!('slug' in module) || !module.slug || typeof module.slug !== 'string' || !module.slug.length) {
19
      output.err('Please set a valid value for module.slug')
20
      return
21
    }
22
23
    callback(module)
24
  })
25
}
26
27
module.exports = Module
28